<style>
    #formorder{padding: 10px 5px 10px 5px;}
    #formorder input,#formorder select{margin: 5px auto;}
    #formorder button{border: 1px solid transparent;background-color: #5bc0de;color: #fff;border-radius: 3px;}

    .page{border-top: 1px solid #E0E0E0;padding: 5px;}
    .page .page_count{padding-top: 5px;}
    .page .page_count label{display: inline-block;line-height: 30px;font-weight: normal;float: left;}
    .page .page_count .paginate_button{
        margin: 0 5px;
        float: left;
        background-color: #D5D5D5;
        padding: 5px 12px;
        color: #7d7d7d;
        border-radius: 3px;
    }
    .page .page_count .paginate_button:hover{
        background-color: #89affc;
        color: #fff;
    }
    .page .page_count .paginate_active{
        margin: 0 5px;
        float: left;
        padding: 5px 12px;
        color: #fff;
        background-color: #89affc;
        border-radius: 3px;
    }


    .cz_clik a{display: inline-block;background: #89affc;color: #fff;padding: 3px 10px;border-radius: 3px;min-width: 76px;text-align: center;}
    .cz_clik a:hover{background: #89bffc;}

</style>
<section class="vbox">
    <section class="scrollable padder">
        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
            <li><a href="#"><i class="fa fa-home"></i>系统设置</a></li>
            <li><a href="#">角色管理</a></li>
            <li><a href="#">角色列表</a></li>
        </ul>
        <div class="m-b-md">
            <h3 class="m-b-none"><span style="float:right;"><a href="#"></a></span>角色列表</h3>
        </div>
        <section class="panel panel-default">
            <header class="panel-heading">
                <i data-title="ajax to load the data." data-placement="bottom" data-toggle="tooltip" class="fa fa-info-sign text-muted" data-original-title="" title=""></i> 
                <b>角色列表</b>
                <a href="<?=$this->url('user/roleEdit')?>" style="float: right;border: 1px solid #5bc0de;background: #5bc0de;color: #fff;padding: 2px 5px;border-radius: 3px;">添加角色</a>
            </header>
            <table data-ride="datatables" class="table table-striped m-b-none dataTable" id="DataTables_Table_0" >
                <thead>
                    <tr role="row">
                        <th>ID</th>
                        <th>名称</th>
                        <th>描述</th>
                        <th>最后操作时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <?
                    if(!empty($re)){
                    foreach($re as $k=>$v){?>
                    <tr role="row">
                        <td><?= $k+1 ?></td>
                        <td><?= $v['title'] ?></td>
                        <td><?= $v['description'] ?></td>
                        <td><?= $v['created'] ?></td>
                        <td>
                            <a href="<?=$this->url("user/roleEdit")."?id=".$v['id']?>" data-original-title="修改" rel="tooltip" class="btn btn-small btn-success" >修改</a>
                            <a href="javascript:void(0);" onclick="status('<?=$v["id"]?>','<?=$v['status']?>')" class="btn btn-small btn-danger show_shadefrist" style="background-color: <?= $v['status'] == 1 ? '' : '#40bf40' ?>;"><?= $v['status'] == 1 ? '冻结' : '使用' ?></a>
                            <a href="javascript:void(0);" onclick="del('<?=$v["id"]?>')" class="btn btn-small btn-danger show_shadefrist" title="删除">删除</a>
                        </td>
                    </tr>
                    <?}
                    }else{?>
                    <tr><td colspan="10">没有相关内容</td></tr>
                    <?}
                    ?>
                </tbody>
            </table>
            <?if($re&&$number>1){?><div class="page"><?=$pageHtml?></div><?}?>
        </section>
    </section>
</section>
<a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a>
<script type="text/javascript">
    function del(id){
        if(confirm("删除后不可恢复！确认删除？")){
            $.ajax({
				type:'POST',
				url:'<?=$this->url("user/roleDel")?>',
				data:'id='+id,
				dataType:'json',
				success:function(r){
					if(r.state==1){
						pub_alert_success(r.html,2000);
						setTimeout(function(){window.location.reload()},1000);
					}else if(r.state==0){
						pub_alert_error(r.html,2000);
					}
				},
                error:function(){
                    pub_alert_error("ajax出现错误",2000);
                }
            });
        }
    }
    function status(id,status){
        if(confirm("是否更改角色状态？")){
            if(status==1){
                var sta=2;
            }else{
                var sta=1;
            }
            $.ajax({
				type:'POST',
				url:'<?=$this->url("user/roleStatus")?>',
				data:{
					'id':id,
					'status':sta
				},
				dataType:'json',
				success:function(r){
					if(r.state==1){
						pub_alert_success(r.html,2000);
						setTimeout(function(){window.location.reload()},1000);
					}else if(r.state==0){
						pub_alert_error(r.html,2000);
					}
				},
                error:function(){
                    pub_alert_error("ajax出现错误",2000);
                }
            });
        }
    }
</script>